<?php
if (!defined("IN_OP"))
{
    exit("You can't access this file directly...");
}
require_once( "class_3d/CheckMode_3d.php" );
$conf = new Config();
$gametype = intval(getvar("gametype"));
$chkGametype = chkGametype($gametype);
$chk = new CheckMode_3d($curruser['acl'], 1, $gametype);
$chk->checkShow3dPage();
$show3D3S = $chk->show3D3S;

$tbl = $g_gametype_3d[$gametype]['en'];
$tblName = $g_gametype_3d[$gametype]['ch'];
$show3D3S = $chk->show3D3S;
$betname = judge_type( $gametype, true );
if ($show3D3S == 2)
{
    require_once( "class_5h/MyLotto_5h.php" );
    require_once( "class_5h/Bet_5h.php" );
    require_once( "class_5h/RateConfig_5h.php" );
    $MyLotto_3d = new MyLotto_5h($gametype);
    $RateConfig_3d = new RateConfig_5h($gametype);
    $_5hFlag = true;
}
elseif ($show3D3S == 3)
{
	require_once( "class_sb/MyLotto_sb.php" );
    require_once( "class_sb/Bet_sb.php" );
    require_once( "class_sb/RateConfig_sb.php" );
    $MyLotto_3d = new MyLotto_sb($gametype);
    $RateConfig_3d = new RateConfig_sb($gametype);
    $_5hFlag = false;		

}
else
{
    require_once( "class_3d/MyLotto_3d.php" );
    require_once( "class_3d/Bet_3d.php" );
    require_once( "class_3d/RateConfig_3d.php" );
    $MyLotto_3d = new MyLotto_3d($gametype);
    $RateConfig_3d = new RateConfig_3d($gametype);
    $_5hFlag = false;
}
$diskBetArr = array();
if ($curruser['disk1'] == 1)
{
    array_push($diskBetArr, $g_disk_codeUP['1']);
}
if ($curruser['disk2'] == 1)
{
    array_push($diskBetArr, $g_disk_codeUP['2']);
}
if ($curruser['disk3'] == 1)
{
    array_push($diskBetArr, $g_disk_codeUP['3']);
}
if ($curruser['disk4'] == 1)
{
    array_push($diskBetArr, $g_disk_codeUP['4']);
}
$diskBetStr = implode(" + ", $diskBetArr);
$diskBetStr = $diskBetStr == "" ? "--" : "{$diskBetStr} 盘";
$open = 0;
$round = 0;
$lotto_id = 0;
$rs = getdb("select * from lotto_{$tbl} where startbet<='" . date("Y-m-d H:i:s") . "' order by open desc limit 1");
if (!$rs->eof)
{
    $open = $rs->f['open'];
    $round = $rs->f['round'];
    $lotto_id = $rs->f['id'];
}
$records = 20;
$list = "";
$rs = getdb("select * from bet_{$tbl} where user_id=" . $_SESSION['uid'] . " and lotto_id=" . $lotto_id . " and rame in (0,9) order by createtime desc, bettype, numbers LIMIT {$records}");
if ($rs->eof)
{
    $list= "<tr class=td2><td colspan=10 align=center>没有下注资料！</td></tr>";
}
else if ($curruser['enabled'] == 1)
{
    $amount = 0;
    $payoff = 0;
    $count = 0;
    while (!$rs->eof)
    {
        $list .= "<tr class=td2 valign=top>";
        $list .= "<td nowrap>" . date("H:i", $rs->f['createtime']) . "</td>";
        $list .= "<td nowrap>" .($show3D3S==3?($betname[$rs->f['bettype']].":".$RateConfig_3d->getBetContent($rs->f['bettype'],$rs->f['numbers'])):"【".$betname[$rs->f['bettype']."_".$rs->f['subid']]."】&nbsp;".nl2br( $rs->f['line_nums'] )) . "</td>";
        $list .= "<td nowrap>" . $g_disk_codeUP[$rs->f['disk']] . "</td>";
        $list .= "<td align=right>" . trimfloat($rs->f['rate'],1) . "</td>";
        $list .= "<td align=right>" . $rs->f['amount'] . "&nbsp;</td>";
        $list .= "</tr>";
        $amount += $rs->f['amount'];
        $payoff += $rs->f['payoff'];
        ++$count;
        $rs->movenext();
    }
   
}
$ui = new UI(false);
$tpl = new Template_Member();
$tpl->load("main" , "left.tpl");
$tpl->set("disk", $diskBetStr);
$tpl->set("account", $curruser['account']);
$tpl->set("name", $curruser['name']);
$tpl->set("amount", $curruser['amount']);
$tpl->set("balance", floatval($curruser['balance']));
//今日输赢
$sy=0;
foreach($g_gametype_3d as $g)
{
	$sql = "SELECT sum(b1) as c FROM bet".($g['en']!="6h"?"_".$g['en']:"")." WHERE user_id='".$curruser['id']."' and createtime>='".(strtotime(date('Y-m-d',time()-3*3600).' 03:00:00'))."' and createtime<='".time()."'";
	$rs = getdb($sql);
	if ( ! $rs->eof )
		$sy+=floatval($rs->f['c']);
}
if($sy<0)
{
	$tpl->set("sycolor" , 'ff0000');	
	$tpl->set("sy" , '－'.abs(round($sy,2)));		
}
else
{
	$tpl->set("sycolor" , '0000ff');	
	$tpl->set("sy" , round($sy,2));			
}	
$tpl->set("tblName",$tblName);
$tpl->set("list0", $list);
if($gametype>=11 && $gametype<=15)
{
	$tpl->set("tbltype",'<div style="padding-top:0px" id="divBtnOpen_5d">
		<input type="button" class="btn btn-primary" onclick="ShowOpen(0)" style="padding:1px 2px ;text-align:center;width:40px;height:23px;" value="号码">
		<input type="button" class="btn btn-primary" onclick="ShowOpen(1)" style="padding:1px 2px ;text-align:center;width:40px;height:23px;" value="大小">
		<input type="button" class="btn btn-primary" onclick="ShowOpen(2)" style="padding:1px 2px ;text-align:center;width:40px;height:23px;" value="单双">
		<input type="button" class="btn btn-primary" onclick="ShowOpen(3)" style="padding:1px 2px ;text-align:center;width:40px;height:23px;" value="质合">
		</div>');	
	require_once("5m_left.php");
}
elseif($gametype==24)
{
	$tpl->set("tbltype",'<div style="padding-top:0px" id="divBtnOpen_5d">
		<input type="button" class="btn btn-primary" onclick="ShowOpen(0)" style="padding:1px 2px ;text-align:center;width:40px;height:23px;" value="号码">
		<input type="button" class="btn btn-primary" onclick="ShowOpen(1)" style="padding:1px 2px ;text-align:center;width:40px;height:23px;" value="大小">
		<input type="button" class="btn btn-primary" onclick="ShowOpen(2)" style="padding:1px 2px ;text-align:center;width:40px;height:23px;" value="单双">
		</div>');	
	require_once("pk_left.php");		
}
elseif($gametype>=20 && $gametype<=23)
{
	$tpl->set("tbltype",'<div style="padding-top:0px" id="divBtnOpen_5d">
		<input type="button" class="btn btn-primary" onclick="ShowOpen(0)" style="padding:1px 2px ;text-align:center;width:40px;height:23px;" value="号码">
		<input type="button" class="btn btn-primary" onclick="ShowOpen(1)" style="padding:1px 2px ;text-align:center;width:40px;height:23px;" value="大小">
		<input type="button" class="btn btn-primary" onclick="ShowOpen(2)" style="padding:1px 2px ;text-align:center;width:40px;height:23px;" value="单双">
		<input type="button" class="btn btn-primary" onclick="ShowOpen(3)" style="padding:1px 2px ;text-align:center;width:40px;height:23px;" value="中发白">
		<input type="button" class="btn btn-primary" onclick="ShowOpen(4)" style="padding:1px 2px ;text-align:center;width:40px;height:23px;" value="方位">
		</div>');	
	require_once("8m_left.php");
}
elseif($gametype>=25 && $gametype<=26)
{
	$tpl->set("tbltype",'<div style="padding-top:0px" id="divBtnOpen_5d">
		</div>');	
	require_once("sb_left.php");
}
//公告
$gonggao = $conf->Get("news_".$g_gametype_3d[$gametype]['en']);
$tpl->set('gonggao',$gonggao);
//
$tpl->set('lotto_list',$table);
$tpl->show("main");